#pragma once

#include "QtBox2DBaseItem.h"

class QtBox2DCollideItem : public QObject, public QtBox2DBaseItem
{
	Q_OBJECT
		Q_PROPERTY(QPointF pos READ pos WRITE setPos)
private:
	QtBox2DCollideItem():QtBox2DBaseItem(0) {} ;
public:
	QtBox2DCollideItem(QtBox2DScene *, QGraphicsItem * parent, float radius);
	virtual ~QtBox2DCollideItem(void);

	void generateName(QtBox2DScene* scene);

	virtual QRectF boundingRect() const;
	void setName(QString name) 
	{
		mName = name;
	}

	virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);

	void setProperty(const QString&	propertyName, const QVariant& value);

protected:
	virtual void	mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
	virtual void	mousePressEvent ( QGraphicsSceneMouseEvent * event );
	virtual void    mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
signals:
	void movedSignal(QtBox2DCollideItem*, const QPointF&);
private:
	float   mRadius;
	QString mControlName;
};

class QtProperty;

class QtBox2DPointCollideItem : public QtBox2DCollideItem
{
	Q_OBJECT
public:
	QtBox2DPointCollideItem(QtBox2DScene *scene, QGraphicsItem * parent, float radius, QtProperty* prop)
		:QtBox2DCollideItem(scene, parent, radius),mProp(prop) {}

	virtual ~QtBox2DPointCollideItem(){};

	void setProperty(const QString &propertyName, const QVariant &value);
protected:
	virtual void	mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
	virtual void	mousePressEvent ( QGraphicsSceneMouseEvent * event );
	virtual void    mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
signals:
	void movedSignal(QtBox2DCollideItem*,QtProperty* prop);
private:
	QtProperty* mProp;
};
